package org.yagnus.langutils.mutables;

public final class MutableInteger {
	int i;

	public final int apply() {
		return i;
	}

	public final int get() {
		return i;
	}

	public final int inc() {
		return (i += 1);
	}

	public final int dec() {
		return (i -= 1);
	}

	public final int inc(int v) {
		return (i += v);
	}

	public final int dec(int v) {
		return (i -= v);
	}

	@Override
	public final int hashCode() {
		return i;
	}

	@Override
	public final boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MutableInteger other = (MutableInteger) obj;
		if (i != other.i)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "MutableInteger [i=" + i + "]";
	}

	public MutableInteger(int i) {
		super();
		this.i = i;
	}

	public final int intValue() {
		return i;
	}

	public final long longValue() {
		return i;
	}

	public final float floatValue() {
		return (float) i;
	}

	public final double doubleValue() {
		return (double) i;
	}
}
